﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

#nullable disable

namespace Model.Models
{
    public partial class LogisticsDBContext : DbContext
    {
        //public LogisticsDBContext()
        //{
        //}

        public LogisticsDBContext(DbContextOptions<LogisticsDBContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Bill> Bills { get; set; }
        public virtual DbSet<Business> Businesses { get; set; }
        public virtual DbSet<Customer> Customers { get; set; }
        public virtual DbSet<Datame> Datames { get; set; }
        public virtual DbSet<Distribute> Distributes { get; set; }
        public virtual DbSet<Employee> Employees { get; set; }
        public virtual DbSet<Firstclass> Firstclasses { get; set; }
        public virtual DbSet<Flitting> Flittings { get; set; }
        public virtual DbSet<Goodsme> Goodsmes { get; set; }
        public virtual DbSet<Mission> Missions { get; set; }
        public virtual DbSet<Order> Orders { get; set; }
        public virtual DbSet<Orderdetail> Orderdetails { get; set; }
        public virtual DbSet<Plan> Plans { get; set; }
        public virtual DbSet<Receipt> Receipts { get; set; }
        public virtual DbSet<Secondclass> Secondclasses { get; set; }
        public virtual DbSet<Station> Stations { get; set; }
        public virtual DbSet<Stock> Stocks { get; set; }
        public virtual DbSet<Stockchange> Stockchanges { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseSqlServer("server= 192.168.14.47;database=LogisticsDB;trusted_connection=false;user id=sa;password=123456");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "Chinese_PRC_CI_AS");

            modelBuilder.Entity<Bill>(entity =>
            {
                entity.HasKey(e => e.Bid)
                    .HasName("PK__bill__DE90ADE76F43B669");

                entity.ToTable("bill");

                entity.Property(e => e.Bid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("bid")
                    .HasDefaultValueSql("((('bi'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Eid).HasColumnName("eid");

                entity.Property(e => e.Oid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("oid");

                entity.Property(e => e.Regdate)
                    .HasColumnType("datetime")
                    .HasColumnName("regdate");

                entity.Property(e => e.Sid).HasColumnName("sid");

                entity.Property(e => e.Status).HasColumnName("status");

                entity.HasOne(d => d.EidNavigation)
                    .WithMany(p => p.Bills)
                    .HasForeignKey(d => d.Eid)
                    .HasConstraintName("FK__bill__eid__4E88ABD4");

                entity.HasOne(d => d.OidNavigation)
                    .WithMany(p => p.Bills)
                    .HasForeignKey(d => d.Oid)
                    .HasConstraintName("FK__bill__oid__4CA06362");

                entity.HasOne(d => d.SidNavigation)
                    .WithMany(p => p.Bills)
                    .HasForeignKey(d => d.Sid)
                    .HasConstraintName("FK__bill__sid__4D94879B");

                entity.HasOne(d => d.StatusNavigation)
                    .WithMany(p => p.Bills)
                    .HasForeignKey(d => d.Status)
                    .HasConstraintName("FK__bill__status__4F7CD00D");
            });

            modelBuilder.Entity<Business>(entity =>
            {
                entity.HasKey(e => e.Bid)
                    .HasName("PK__business__DE90ADE7B5DD8567");

                entity.ToTable("business");

                entity.Property(e => e.Bid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("bid")
                    .HasDefaultValueSql("((('b'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Account)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("account");

                entity.Property(e => e.Accountbank)
                    .HasMaxLength(30)
                    .IsUnicode(false)
                    .HasColumnName("accountbank");

                entity.Property(e => e.Address)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("address");

                entity.Property(e => e.Bname)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("bname");

                entity.Property(e => e.Fax)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("fax");

                entity.Property(e => e.Legalman)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("legalman");

                entity.Property(e => e.Linkman)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("linkman");

                entity.Property(e => e.Post)
                    .HasMaxLength(6)
                    .IsUnicode(false)
                    .HasColumnName("post");

                entity.Property(e => e.Remark)
                    .HasMaxLength(200)
                    .IsUnicode(false)
                    .HasColumnName("remark");

                entity.Property(e => e.Tel)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("tel");
            });

            modelBuilder.Entity<Customer>(entity =>
            {
                entity.HasKey(e => e.Cid)
                    .HasName("PK__customer__D837D05F9B32643F");

                entity.ToTable("customer");

                entity.Property(e => e.Cid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("cid")
                    .HasDefaultValueSql("((('ct'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Address)
                    .HasMaxLength(40)
                    .IsUnicode(false)
                    .HasColumnName("address");

                entity.Property(e => e.Area)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("area");

                entity.Property(e => e.Card)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("card");

                entity.Property(e => e.Cname)
                    .IsRequired()
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("cname");

                entity.Property(e => e.Email)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("email");

                entity.Property(e => e.Mobile)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("mobile");

                entity.Property(e => e.Post)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("post");

                entity.Property(e => e.Tel)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("tel");

                entity.Property(e => e.Work)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("work");
            });

            modelBuilder.Entity<Datame>(entity =>
            {
                entity.HasKey(e => e.Dtid)
                    .HasName("PK__datames__24BF1B14DEDD5DD4");

                entity.ToTable("datames");

                entity.Property(e => e.Dtid).HasColumnName("dtid");

                entity.Property(e => e.Des)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("des");

                entity.Property(e => e.Dname)
                    .IsRequired()
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("dname");

                entity.Property(e => e.Dtype)
                    .IsRequired()
                    .HasMaxLength(10)
                    .IsUnicode(false)
                    .HasColumnName("dtype");
            });

            modelBuilder.Entity<Distribute>(entity =>
            {
                entity.HasKey(e => e.Did)
                    .HasName("PK__distribu__D877D2166E88C727");

                entity.ToTable("distribute");

                entity.Property(e => e.Did)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("did")
                    .HasDefaultValueSql("((('d'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Counts).HasColumnName("counts");

                entity.Property(e => e.Ddate)
                    .HasColumnType("datetime")
                    .HasColumnName("ddate");

                entity.Property(e => e.Dmoney)
                    .HasColumnType("money")
                    .HasColumnName("dmoney");

                entity.Property(e => e.Dover).HasColumnName("dover");

                entity.Property(e => e.Gid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("gid");

                entity.Property(e => e.Odid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("odid");

                entity.Property(e => e.Remark)
                    .HasMaxLength(100)
                    .IsUnicode(false)
                    .HasColumnName("remark");

                entity.Property(e => e.Sid).HasColumnName("sid");

                entity.HasOne(d => d.GidNavigation)
                    .WithMany(p => p.Distributes)
                    .HasForeignKey(d => d.Gid)
                    .HasConstraintName("FK__distribute__gid__619B8048");

                entity.HasOne(d => d.Od)
                    .WithMany(p => p.Distributes)
                    .HasForeignKey(d => d.Odid)
                    .HasConstraintName("FK__distribute__odid__60A75C0F");

                entity.HasOne(d => d.SidNavigation)
                    .WithMany(p => p.Distributes)
                    .HasForeignKey(d => d.Sid)
                    .HasConstraintName("FK__distribute__sid__628FA481");
            });

            modelBuilder.Entity<Employee>(entity =>
            {
                entity.HasKey(e => e.Eid)
                    .HasName("PK__employee__D9509F6D3FD33EBE");

                entity.ToTable("employee");

                entity.Property(e => e.Eid).HasColumnName("eid");

                entity.Property(e => e.Ename)
                    .IsRequired()
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("ename");

                entity.Property(e => e.Position).HasColumnName("position");

                entity.Property(e => e.Pwd)
                    .IsRequired()
                    .HasMaxLength(20)
                    .IsUnicode(false);

                entity.Property(e => e.Remark)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("remark");

                entity.HasOne(d => d.PositionNavigation)
                    .WithMany(p => p.Employees)
                    .HasForeignKey(d => d.Position)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__employee__positi__1273C1CD");
            });

            modelBuilder.Entity<Firstclass>(entity =>
            {
                entity.HasKey(e => e.Fcid)
                    .HasName("PK__firstcla__30F11BAEFB520305");

                entity.ToTable("firstclass");

                entity.Property(e => e.Fcid).HasColumnName("fcid");

                entity.Property(e => e.Des)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("des");

                entity.Property(e => e.Fcname)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("fcname");
            });

            modelBuilder.Entity<Flitting>(entity =>
            {
                entity.HasKey(e => e.Fid)
                    .HasName("PK__flitting__D9908D64808064F0");

                entity.ToTable("flitting");

                entity.Property(e => e.Fid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("fid")
                    .HasDefaultValueSql("((('f'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Flitdate)
                    .HasColumnType("datetime")
                    .HasColumnName("flitdate");

                entity.Property(e => e.Fover).HasColumnName("fover");

                entity.Property(e => e.Ftype).HasColumnName("ftype");

                entity.Property(e => e.Oid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("oid");

                entity.Property(e => e.Sid).HasColumnName("sid");

                entity.HasOne(d => d.FtypeNavigation)
                    .WithMany(p => p.Flittings)
                    .HasForeignKey(d => d.Ftype)
                    .HasConstraintName("FK__flitting__ftype__3F466844");

                entity.HasOne(d => d.OidNavigation)
                    .WithMany(p => p.Flittings)
                    .HasForeignKey(d => d.Oid)
                    .HasConstraintName("FK__flitting__oid__3E52440B");

                entity.HasOne(d => d.SidNavigation)
                    .WithMany(p => p.Flittings)
                    .HasForeignKey(d => d.Sid)
                    .HasConstraintName("FK__flitting__sid__412EB0B6");
            });

            modelBuilder.Entity<Goodsme>(entity =>
            {
                entity.HasKey(e => e.Gid)
                    .HasName("PK__goodsmes__DCD80EF8E7CC3814");

                entity.ToTable("goodsmes");

                entity.Property(e => e.Gid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("gid")
                    .HasDefaultValueSql("((('g'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Bid)
                    .IsRequired()
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("bid");

                entity.Property(e => e.Company)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("company");

                entity.Property(e => e.Costprice)
                    .HasColumnType("money")
                    .HasColumnName("costprice");

                entity.Property(e => e.Discount).HasColumnName("discount");

                entity.Property(e => e.Formprice)
                    .HasColumnType("money")
                    .HasColumnName("formprice");

                entity.Property(e => e.Gname)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("gname");

                entity.Property(e => e.Isexc).HasColumnName("isexc");

                entity.Property(e => e.Isret).HasColumnName("isret");

                entity.Property(e => e.Keepdate)
                    .HasColumnType("datetime")
                    .HasColumnName("keepdate");

                entity.Property(e => e.Model)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("model");

                entity.Property(e => e.Most).HasColumnName("most");

                entity.Property(e => e.Remark)
                    .HasMaxLength(100)
                    .IsUnicode(false)
                    .HasColumnName("remark");

                entity.Property(e => e.Sdid).HasColumnName("sdid");

                entity.Property(e => e.Unit)
                    .HasMaxLength(10)
                    .IsUnicode(false)
                    .HasColumnName("unit");

                entity.Property(e => e.Warning).HasColumnName("warning");

                entity.HasOne(d => d.BidNavigation)
                    .WithMany(p => p.Goodsmes)
                    .HasForeignKey(d => d.Bid)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__goodsmes__bid__21B6055D");

                entity.HasOne(d => d.Sd)
                    .WithMany(p => p.Goodsmes)
                    .HasForeignKey(d => d.Sdid)
                    .HasConstraintName("FK__goodsmes__sdid__20C1E124");
            });

            modelBuilder.Entity<Mission>(entity =>
            {
                entity.HasKey(e => e.Mid)
                    .HasName("PK__mission__DF5032EC06DF3BFA");

                entity.ToTable("mission");

                entity.Property(e => e.Mid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("mid")
                    .HasDefaultValueSql("((('m'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Comitedate)
                    .HasColumnType("datetime")
                    .HasColumnName("comitedate");

                entity.Property(e => e.Createdate)
                    .HasColumnType("datetime")
                    .HasColumnName("createdate");

                entity.Property(e => e.Fid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("fid");

                entity.Property(e => e.Mtype).HasColumnName("mtype");

                entity.Property(e => e.Oid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("oid");

                entity.Property(e => e.Remark)
                    .HasMaxLength(100)
                    .IsUnicode(false)
                    .HasColumnName("remark");

                entity.Property(e => e.Sid).HasColumnName("sid");

                entity.Property(e => e.Status).HasColumnName("status");

                entity.Property(e => e.Totalmoney)
                    .HasColumnType("money")
                    .HasColumnName("totalmoney");

                entity.HasOne(d => d.FidNavigation)
                    .WithMany(p => p.Missions)
                    .HasForeignKey(d => d.Fid)
                    .HasConstraintName("FK__mission__fid__45F365D3");

                entity.HasOne(d => d.MtypeNavigation)
                    .WithMany(p => p.MissionMtypeNavigations)
                    .HasForeignKey(d => d.Mtype)
                    .HasConstraintName("FK__mission__mtype__47DBAE45");

                entity.HasOne(d => d.OidNavigation)
                    .WithMany(p => p.Missions)
                    .HasForeignKey(d => d.Oid)
                    .HasConstraintName("FK__mission__oid__44FF419A");

                entity.HasOne(d => d.SidNavigation)
                    .WithMany(p => p.Missions)
                    .HasForeignKey(d => d.Sid)
                    .HasConstraintName("FK__mission__sid__46E78A0C");

                entity.HasOne(d => d.StatusNavigation)
                    .WithMany(p => p.MissionStatusNavigations)
                    .HasForeignKey(d => d.Status)
                    .HasConstraintName("FK__mission__status__48CFD27E");
            });

            modelBuilder.Entity<Order>(entity =>
            {
                entity.HasKey(e => e.Oid)
                    .HasName("PK__orders__C2FFCF13CBC6B464");

                entity.ToTable("orders");

                entity.Property(e => e.Oid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("oid")
                    .HasDefaultValueSql("((('o'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Address)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("address");

                entity.Property(e => e.Bill).HasColumnName("bill");

                entity.Property(e => e.Cid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("cid");

                entity.Property(e => e.Comitedate)
                    .HasColumnType("datetime")
                    .HasColumnName("comitedate");

                entity.Property(e => e.Createdate)
                    .HasColumnType("datetime")
                    .HasColumnName("createdate");

                entity.Property(e => e.Managedate)
                    .HasColumnType("datetime")
                    .HasColumnName("managedate");

                entity.Property(e => e.Manager).HasColumnName("manager");

                entity.Property(e => e.Managereason)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("managereason");

                entity.Property(e => e.Oderid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("oderid");

                entity.Property(e => e.Otype).HasColumnName("otype");

                entity.Property(e => e.Payaddress)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("payaddress");

                entity.Property(e => e.Payman)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("payman");

                entity.Property(e => e.Paypost)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("paypost");

                entity.Property(e => e.Paytel)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("paytel");

                entity.Property(e => e.Receiveman)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("receiveman");

                entity.Property(e => e.Receivepost)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("receivepost");

                entity.Property(e => e.Receivetel)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("receivetel");

                entity.Property(e => e.Remark)
                    .HasMaxLength(100)
                    .IsUnicode(false)
                    .HasColumnName("remark");

                entity.Property(e => e.Sid).HasColumnName("sid");

                entity.Property(e => e.Status).HasColumnName("status");

                entity.HasOne(d => d.CidNavigation)
                    .WithMany(p => p.Orders)
                    .HasForeignKey(d => d.Cid)
                    .HasConstraintName("FK__orders__cid__2E1BDC42");

                entity.HasOne(d => d.ManagerNavigation)
                    .WithMany(p => p.Orders)
                    .HasForeignKey(d => d.Manager)
                    .HasConstraintName("FK__orders__manager__32E0915F");

                entity.HasOne(d => d.OtypeNavigation)
                    .WithMany(p => p.OrderOtypeNavigations)
                    .HasForeignKey(d => d.Otype)
                    .HasConstraintName("FK__orders__otype__300424B4");

                entity.HasOne(d => d.SidNavigation)
                    .WithMany(p => p.Orders)
                    .HasForeignKey(d => d.Sid)
                    .HasConstraintName("FK__orders__sid__2F10007B");

                entity.HasOne(d => d.StatusNavigation)
                    .WithMany(p => p.OrderStatusNavigations)
                    .HasForeignKey(d => d.Status)
                    .HasConstraintName("FK__orders__status__31EC6D26");
            });

            modelBuilder.Entity<Orderdetail>(entity =>
            {
                entity.HasKey(e => e.Odid)
                    .HasName("PK__orderdet__8D153E09891B2525");

                entity.ToTable("orderdetail");

                entity.Property(e => e.Odid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("odid")
                    .HasDefaultValueSql("((('od'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Cid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("cid");

                entity.Property(e => e.Counts).HasColumnName("counts");

                entity.Property(e => e.Gid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("gid");

                entity.Property(e => e.Litter).HasColumnName("litter");

                entity.Property(e => e.Managedate)
                    .HasColumnType("datetime")
                    .HasColumnName("managedate");

                entity.Property(e => e.Manager).HasColumnName("manager");

                entity.Property(e => e.Managereason)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("managereason");

                entity.Property(e => e.Oid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("oid");

                entity.Property(e => e.Planmoney)
                    .HasColumnType("money")
                    .HasColumnName("planmoney");

                entity.Property(e => e.Realmoney)
                    .HasColumnType("money")
                    .HasColumnName("realmoney");

                entity.Property(e => e.Remark)
                    .HasMaxLength(100)
                    .IsUnicode(false)
                    .HasColumnName("remark");

                entity.Property(e => e.Totalmoney)
                    .HasColumnType("money")
                    .HasColumnName("totalmoney");

                entity.HasOne(d => d.CidNavigation)
                    .WithMany(p => p.Orderdetails)
                    .HasForeignKey(d => d.Cid)
                    .HasConstraintName("FK__orderdetail__cid__37A5467C");

                entity.HasOne(d => d.GidNavigation)
                    .WithMany(p => p.Orderdetails)
                    .HasForeignKey(d => d.Gid)
                    .HasConstraintName("FK__orderdetail__gid__38996AB5");

                entity.HasOne(d => d.ManagerNavigation)
                    .WithMany(p => p.Orderdetails)
                    .HasForeignKey(d => d.Manager)
                    .HasConstraintName("FK__orderdeta__manag__398D8EEE");

                entity.HasOne(d => d.OidNavigation)
                    .WithMany(p => p.Orderdetails)
                    .HasForeignKey(d => d.Oid)
                    .HasConstraintName("FK__orderdetail__oid__36B12243");
            });

            modelBuilder.Entity<Plan>(entity =>
            {
                entity.HasKey(e => e.Pid)
                    .HasName("PK__plans__DD37D91AB7EA63F5");

                entity.ToTable("plans");

                entity.Property(e => e.Pid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("pid")
                    .HasDefaultValueSql("((('p'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Account).HasColumnName("account");

                entity.Property(e => e.Counts).HasColumnName("counts");

                entity.Property(e => e.Executestatus).HasColumnName("executestatus");

                entity.Property(e => e.Gid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("gid");

                entity.Property(e => e.Handle).HasColumnName("handle");

                entity.Property(e => e.Managedate)
                    .HasColumnType("datetime")
                    .HasColumnName("managedate");

                entity.Property(e => e.Managetype).HasColumnName("managetype");

                entity.Property(e => e.Remark)
                    .HasMaxLength(100)
                    .IsUnicode(false)
                    .HasColumnName("remark");

                entity.HasOne(d => d.ExecutestatusNavigation)
                    .WithMany(p => p.PlanExecutestatusNavigations)
                    .HasForeignKey(d => d.Executestatus)
                    .HasConstraintName("FK__plans__executest__5BE2A6F2");

                entity.HasOne(d => d.GidNavigation)
                    .WithMany(p => p.Plans)
                    .HasForeignKey(d => d.Gid)
                    .HasConstraintName("FK__plans__gid__59063A47");

                entity.HasOne(d => d.HandleNavigation)
                    .WithMany(p => p.Plans)
                    .HasForeignKey(d => d.Handle)
                    .HasConstraintName("FK__plans__handle__5AEE82B9");

                entity.HasOne(d => d.ManagetypeNavigation)
                    .WithMany(p => p.PlanManagetypeNavigations)
                    .HasForeignKey(d => d.Managetype)
                    .HasConstraintName("FK__plans__managetyp__59FA5E80");
            });

            modelBuilder.Entity<Receipt>(entity =>
            {
                entity.HasKey(e => e.Rid)
                    .HasName("PK__receipt__C2B7EDE8D01076DA");

                entity.ToTable("receipt");

                entity.Property(e => e.Rid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("rid")
                    .HasDefaultValueSql("((('r'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Collback).HasColumnName("collback");

                entity.Property(e => e.Mid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("mid");

                entity.Property(e => e.Oid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("oid");

                entity.HasOne(d => d.CollbackNavigation)
                    .WithMany(p => p.Receipts)
                    .HasForeignKey(d => d.Collback)
                    .HasConstraintName("FK__receipt__collbac__5535A963");

                entity.HasOne(d => d.MidNavigation)
                    .WithMany(p => p.Receipts)
                    .HasForeignKey(d => d.Mid)
                    .HasConstraintName("FK__receipt__mid__534D60F1");

                entity.HasOne(d => d.OidNavigation)
                    .WithMany(p => p.Receipts)
                    .HasForeignKey(d => d.Oid)
                    .HasConstraintName("FK__receipt__oid__5441852A");
            });

            modelBuilder.Entity<Secondclass>(entity =>
            {
                entity.HasKey(e => e.Sdid)
                    .HasName("PK__secondcl__2CCC84DE45CBAF21");

                entity.ToTable("secondclass");

                entity.Property(e => e.Sdid).HasColumnName("sdid");

                entity.Property(e => e.Des)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .HasColumnName("des");

                entity.Property(e => e.Fcid).HasColumnName("fcid");

                entity.Property(e => e.Sdname)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("sdname");

                entity.HasOne(d => d.Fc)
                    .WithMany(p => p.Secondclasses)
                    .HasForeignKey(d => d.Fcid)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__secondclas__fcid__1A14E395");
            });

            modelBuilder.Entity<Station>(entity =>
            {
                entity.HasKey(e => e.Sid)
                    .HasName("PK__station__DDDFDD36C5CBF473");

                entity.ToTable("station");

                entity.Property(e => e.Sid).HasColumnName("sid");

                entity.Property(e => e.Addmin)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("addmin");

                entity.Property(e => e.Levels).HasColumnName("levels");

                entity.Property(e => e.Saddress)
                    .HasMaxLength(30)
                    .IsUnicode(false)
                    .HasColumnName("saddress");

                entity.Property(e => e.Sname)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("sname");

                entity.HasOne(d => d.LevelsNavigation)
                    .WithMany(p => p.Stations)
                    .HasForeignKey(d => d.Levels)
                    .HasConstraintName("FK__station__levels__267ABA7A");
            });

            modelBuilder.Entity<Stock>(entity =>
            {
                entity.HasKey(e => e.Stid)
                    .HasName("PK__stock__312D1FC704A9EC4C");

                entity.ToTable("stock");

                entity.Property(e => e.Stid).HasColumnName("stid");

                entity.Property(e => e.Gid)
                    .IsRequired()
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("gid");

                entity.Property(e => e.Sid).HasColumnName("sid");

                entity.Property(e => e.Stoks).HasColumnName("stoks");

                entity.HasOne(d => d.GidNavigation)
                    .WithMany(p => p.Stocks)
                    .HasForeignKey(d => d.Gid)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK__stock__gid__29572725");

                entity.HasOne(d => d.SidNavigation)
                    .WithMany(p => p.Stocks)
                    .HasForeignKey(d => d.Sid)
                    .HasConstraintName("FK__stock__sid__2A4B4B5E");
            });

            modelBuilder.Entity<Stockchange>(entity =>
            {
                entity.HasKey(e => e.Scid)
                    .HasName("PK__stockcha__320EA6B582A38A17");

                entity.ToTable("stockchange");

                entity.Property(e => e.Scid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("scid")
                    .HasDefaultValueSql("((('sc'+datename(hour,getdate()))+datename(minute,getdate()))+datename(second,getdate()))");

                entity.Property(e => e.Counts).HasColumnName("counts");

                entity.Property(e => e.Did)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("did");

                entity.Property(e => e.Eid).HasColumnName("eid");

                entity.Property(e => e.Geteid).HasColumnName("geteid");

                entity.Property(e => e.Gid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("gid");

                entity.Property(e => e.Mid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("mid");

                entity.Property(e => e.Odid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("odid");

                entity.Property(e => e.Pid)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("pid");

                entity.Property(e => e.Remark)
                    .HasMaxLength(100)
                    .IsUnicode(false)
                    .HasColumnName("remark");

                entity.Property(e => e.Sdate)
                    .HasColumnType("datetime")
                    .HasColumnName("sdate");

                entity.Property(e => e.Sid).HasColumnName("sid");

                entity.Property(e => e.Stype).HasColumnName("stype");

                entity.Property(e => e.Totalmoney)
                    .HasColumnType("money")
                    .HasColumnName("totalmoney");

                entity.HasOne(d => d.DidNavigation)
                    .WithMany(p => p.Stockchanges)
                    .HasForeignKey(d => d.Did)
                    .HasConstraintName("FK__stockchange__did__68487DD7");

                entity.HasOne(d => d.EidNavigation)
                    .WithMany(p => p.StockchangeEidNavigations)
                    .HasForeignKey(d => d.Eid)
                    .HasConstraintName("FK__stockchange__eid__6E01572D");

                entity.HasOne(d => d.Gete)
                    .WithMany(p => p.StockchangeGetes)
                    .HasForeignKey(d => d.Geteid)
                    .HasConstraintName("FK__stockchan__getei__6D0D32F4");

                entity.HasOne(d => d.GidNavigation)
                    .WithMany(p => p.Stockchanges)
                    .HasForeignKey(d => d.Gid)
                    .HasConstraintName("FK__stockchange__gid__6B24EA82");

                entity.HasOne(d => d.MidNavigation)
                    .WithMany(p => p.Stockchanges)
                    .HasForeignKey(d => d.Mid)
                    .HasConstraintName("FK__stockchange__mid__693CA210");

                entity.HasOne(d => d.Od)
                    .WithMany(p => p.Stockchanges)
                    .HasForeignKey(d => d.Odid)
                    .HasConstraintName("FK__stockchang__odid__6A30C649");

                entity.HasOne(d => d.PidNavigation)
                    .WithMany(p => p.Stockchanges)
                    .HasForeignKey(d => d.Pid)
                    .HasConstraintName("FK__stockchange__pid__6754599E");

                entity.HasOne(d => d.SidNavigation)
                    .WithMany(p => p.Stockchanges)
                    .HasForeignKey(d => d.Sid)
                    .HasConstraintName("FK__stockchange__sid__6C190EBB");

                entity.HasOne(d => d.StypeNavigation)
                    .WithMany(p => p.Stockchanges)
                    .HasForeignKey(d => d.Stype)
                    .HasConstraintName("FK__stockchan__stype__6EF57B66");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
